#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/sched/signal.h>

static int __init print_process_names_init(void)
{
    struct task_struct *task;

    printk(KERN_INFO "List of all processes:\n");

    // 遍历任务链表
    for_each_process(task) {
        printk(KERN_INFO "Process: %s\n", task->comm);
    }

    return 0;
}

static void __exit print_process_names_exit(void)
{
    printk(KERN_INFO "Module exit.\n");
}

module_init(print_process_names_init);
module_exit(print_process_names_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Print names of all processes");
